package com.kkb.proxy.statix;

import com.kkb.service.IService;

/**
 * @author ztranscript 2021/8/28 14:27
 **/
public class OrderServiceProxy implements IService {
    /**
     * 被代理的对象
     */
    private IService service;

    /**
     * AOP 对象
     */
    private AOP aop;

    public OrderServiceProxy(IService service, AOP aop) {
        this.service = service;
        this.aop = aop;
    }

    /**
     * @return 订单总数
     */
    @Override
    public int selectCount() {
        try {
            aop.before();
            // 被代理对象干活
            int count = service.selectCount();
            aop.after();
            return count;
        } catch (Exception e) {
            aop.exception();
        } finally {
            aop.myFinally();
        }
        return -1;
    }
}
